{extend name='base'}
{block name='content'}
<!--页面主要内容-->
<main class="lyear-layout-content">

    <div class="container-fluid">

        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header">
                        <h4>用户列表</h4>
                    </div>
                    <div class="card-toolbar clearfix">
                        <form class="search-bar" method="post" action="{:url('admin/user/search')}" role="form">
                            <div class="input-group">
                                <input type="text" class="form-control" value="" name="phone" required placeholder="请输入手机号">
                                <div class="input-group-btn">
                                    <button class="btn btn-default"  type="submit" >
                                        搜索
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>手机号</th>
                                    <th>注册时间</th>
                                    <th>状态</th>
                                    <th width="200">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {if !empty($user)}
                                <tr>
                                    <td>{$user.user_id}</td>
                                    <td>{$user.user_name}</td>
                                    <td>{:date('Y-m-d',$user.user_creat_time)}</td>

                                    {if $user.user_state}
                                    <td style="color:#33cabb; ">正常</td>
                                    {else/}
                                    <td style="color:#f96868; ">禁用</td>
                                    {/if}

                                    <td>
                                        <div class="btn-group">
                                            {if $user.user_state}
                                            <a class="btn btn-danger btn-sm" onclick="changeState('{$user.user_id}')" >封禁</a>
                                            {else/}
                                            <a class="btn btn-success btn-sm" onclick="changeState('{$user.user_id}')" >解封</a>
                                            {/if}

                                        </div>
                                    </td>
                                </tr>
                                {else /}
                                <tr><td>无此用户</td></tr>
                                {/if}
                                </tbody>
                            </table>
                        </div>


                    </div>
                </div>
            </div>

        </div>

    </div>

</main>
<!--End 页面主要内容-->
<script>
    layui.use('layer', function(){
        var layer = layui.layer;

    };
</script>
<script>
    function changeState(user_id) {
        $.post("{:url('admin/user/changeState')}",{id:user_id},function (res) {
            if(res.code){
                layer.msg("操作成功",{icon:1});
                setTimeout(function () {
                    location.reload();
                },2000)
            }
        })
    }
</script>
{/block}